//
//  MainViewController.swift
//  WeiBoText
//
//  Created by 刘世瑛 on 16/1/10.
//  Copyright © 2016年 刘世瑛. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    
    
    
    
    func addChildViewControllers() {
       
        addChildViewController(HomeTableViewController(), imageName: "tabbar_home", title: "首页")
     
        addChildViewController(MessageTableViewController(), imageName: "tabbar_message_center", title: "消息")

        addChildViewController(DiscoverTableViewController(), imageName: "tabbar_discover", title: "发现")

        addChildViewController(ProfileTableViewController(), imageName: "tabbar_profile", title: "我")
    }
    
    func addChildViewController(childController: UIViewController,imageName:String,title:String) {
        
      childController.tabBarItem.image = UIImage(named: imageName)
    
      childController.title = title
      
        
        _ = {
            //vc.tabBarItem.selectedImage = UIImage(named: imageName + "_highlighted")?.imageWithRenderingMode(.AlwaysOriginal)
            //
            //        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: .Selected)
            
            //设置title
            //        home.tabBarItem.title = "首页"_highlighted
            //        home.navigationItem.title = "首页"
     
        }
        
    let vc = UINavigationController(rootViewController: childController)
    vc.navigationItem.title = title
     addChildViewController(vc)
        
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    //设置自定义tabBar
        setValue(MainTabbar(), forKey: "tabBar")
        addChildViewControllers()
//      self.tabBar.tintColor = UIColor.orangeColor()
        // Do any additional setup after loading the view.
    }

  


}
